<template>
  <div>
    <div class="introduceBox">
      <div class="imgBox">
        <img :src="detail && detail.picUrl" alt="" />
      </div>
      <div class="introduceBoxRight">
        <div class="introduceBoxTitle">
          <p class="label"></p>
          <div class="songSheetName" :title="detail && detail.name">
            {{ detail && detail.name }}
          </div>
        </div>
        <div class="userBox">
          <p class="nickname">
            <i>歌手：</i>{{ detail && detail.artist.name }}
          </p>
          <p class="albumName"><i>所属专辑：</i> {{ detail && detail.name }}</p>
          <span></span>
        </div>
        <div class="btnBox">
          <div class="playBtn" @click="songSheetPlay(musicList)">
            <i></i>
            <span>播放</span>
          </div>
          <div class="addSongSheet" @click="addMusicList(detail.tracks)"></div>
          <div class="btnClass">
            <i>收藏</i>
          </div>
          <div class="btnClass forward">
            <i>分享</i>
          </div>
          <div class="btnClass download">
            <i>下载</i>
          </div>
          <div class="btnClass comment">
            <i>{{ 435879 | numChange }}</i>
          </div>
        </div>
      </div>
    </div>
    <div class="introduceBoxBot">
      <h3>专辑介绍：</h3>
      <pre :class="isOPen ? 'descriptionte' : 'description'">
        {{ detail && detail.description }}
      </pre>
      <span class="openBtn" v-if="!isOPen" @click="isOPen = true"
        >展开<i></i
      ></span>
      <span class="PutItAwayBtn" v-if="isOPen" @click="isOPen = false"
        >收起<i></i
      ></span>
    </div>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  props: {
    detail: {
      type: Object,
      default: undefined,
    },
    musicList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      isOPen: false,
    };
  },
  filters: {
    numChange(num) {
      if (num > 99999) {
        return parseInt(num / 10000) + "万";
      } else {
        return num;
      }
    },
  },
  methods: {
    ...mapActions("musicStore", ["songSheetPlay", "addMusicList"]),
  },
};
</script>

<style lang="scss" scoped>
.introduceBox {
  width: 100%;
  display: flex;
  .imgBox {
    width: 200px;
    height: 200px;
    padding: 2px;
    border: 1px solid #ccc;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .introduceBoxRight {
    flex: 1;
    overflow: hidden;
    margin-left: 30px;
    .introduceBoxTitle {
      display: flex;
      .label {
        width: 54px;
        height: 24px;
        background: url("./../../assets/imges/btnIconTwo.png") no-repeat 0 -186px;
        margin-right: 10px;
      }
      .songSheetName {
        flex: 1;
        line-height: 24px;
        font-size: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
    .userBox {
      .nickname,
      .albumName {
        color: #0c73c2;
        margin: 10px 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        i {
          color: #999;
        }
      }
    }
    .btnBox {
      .playBtn {
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat 0 -387px;
        padding: 0 5px 0 0;
        height: 31px;
        display: inline-block;
        color: #fff;
        vertical-align: middle;
        cursor: pointer;
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1622px;
          width: 20px;
          height: 18px;
          margin: 6px 2px 2px 5px;
          display: inline-block;
          vertical-align: middle;
        }
        span {
          vertical-align: middle;
        }
      }
      .addSongSheet {
        margin-right: 5px;
        line-height: 30px;
        width: 31px;
        display: inline-block;
        height: 31px;
        vertical-align: middle;
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat 0 -1588px;
      }
      .btnClass {
        color: #333;
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat
          right -1020px;
        padding: 0 5px 0 0;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
        margin-right: 5px;
        i {
          padding-right: 2px;
          padding-left: 28px;
          height: 31px;
          line-height: 30px;
          display: inline-block;
          min-width: 23px;
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -977px;
          cursor: pointer;
        }
      }
      .forward {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1225px;
        }
      }
      .download {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -2761px;
        }
      }
      .comment {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1465px;
        }
      }
    }
  }
}
.introduceBoxBot {
  margin-top: 20px;
  .description {
    color: #666;
    line-height: 24px;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 10;
    white-space: pre-wrap;
    word-wrap: break-word;
  }
  .descriptionte {
    color: #666;
    line-height: 24px;
    white-space: pre-wrap;
    word-wrap: break-word;
  }
  .openBtn {
    color: #0c73c2;
    float: right;
    i {
      width: 11px;
      margin-left: 3px;
      height: 8px;
      display: inline-block;
      background: url("./../../assets/imges/btnIconTwo.png") no-repeat -65px -520px;
    }
  }
  .PutItAwayBtn {
    color: #0c73c2;
    float: right;
    i {
      width: 11px;
      margin-left: 3px;
      height: 8px;
      display: inline-block;
      background: url("./../../assets/imges/btnIconTwo.png") no-repeat -45px -520px;
    }
  }
}
</style>